<div class="bjui-pageContent">
    <form action="${wwwroot}/admin/job/save" id="editForm" data-toggle="validate" data-alertmsg="false" reloadNavtab="true">
        <input type="hidden" name="id" value="${(job.id)!}" />
        <input type="hidden" name="subjectId" value="${(job.subjectId)!}" />


        <div class="pageFormContent" data-layout-h="0">
            <table class="table table-condensed table-hover" width="100%">
                <tbody>
                <tr>
                    <td>
                        <label for="name" class="control-label x85">名称：</label>
                        <input type="text" name="name" id="name" value="${(job.name)!}" data-rule="required" >
                    </td>
                    <td>
                        <label for="note" class="control-label x85">说明：</label>
                        <input type="text" name="note" id="note" value="${(job.note)!}" data-rule="required" >
                    </td>

                </tr>
                </tbody>
            </table>
            是否定时：
            <input type="radio" class="isTimer" name="isTimer"  value="0" data-toggle="icheck" data-label="否" checked>
            <input type="radio" class="isTimer" name="isTimer"  value="1" data-toggle="icheck" data-label="是" >
            <div style="height:20%; overflow:hidden;">
                <fieldset style="height:100%;">
                    <legend>业务单元</legend>
                    <table class="table table-hover">
                        <thead>
                        <tr>
                            <th width="50%">业务单元</th>
                            <th width="50%">发布时间</th>
                        </tr>
                        </thead>
                        <tbody>
                        <#list bizUnits as bizUnit>
                            <#if subjectBizUnitMap[bizUnit.unitName]??>
                                <#assign checked =true/>
                            <#else>
                                <#assign checked =false/>
                            </#if>
                        <#if checked>
                        <tr>
                            <td>
                                <input type="checkbox" name="bizUnitArray"  value="${(bizUnit.unitName)!}" data-toggle="icheck" data-label="${(bizUnit.note)!}" <#if checked>checked</#if> >
                            </td>
                            <td>
                                <input style="display:none" type="text" name="planDateArray"  class="secondDate" value=""   size="20">
                            </td>
                        </tr>
                        </#if>
                        </#list>
                        </tbody>
                    </table>
                </fieldset>
            </div>
            <div style="height:20%; overflow:hidden;">
                <fieldset style="height:100%;">
                    <legend>业务类型</legend>
                    <div  style="height:94%; overflow:hidden;">
                    <#list bizTypes as bizType>
                        <#if subjectBizTypeMap[bizType.typeName]??>
                            <#assign checked =true/>
                        <#else>
                            <#assign checked =false/>
                        </#if>
                        <#if checked>
                        <input type="checkbox" name="bizTypeArray"  value="${(bizType.typeName)!}" data-toggle="icheck" data-label="${(bizType.note)!}" <#if checked>checked</#if>>
                        </#if>
                    </#list>
                    </div>
                </fieldset>
            </div>


            <div style="height:20%; overflow:hidden;">
                <fieldset style="height:100%;">
                    <legend>前置脚本</legend>
                    <a href="/admin/prescript/lookup" id="psLookup" data-toggle="lookupbtn" data-group="preScript">选择前置脚本</a>
                    <div style="height:94%; overflow:hidden;">
                        <input type="hidden" id="preScript.id" name="preScript.id" value="">
                        <input type="text" id="preScript.name" name="preScript.name" value="" size="50" readonly>
                        <table id="datagrid-table"></table>
                    </div>
                </fieldset>
            </div>
            <div style="height:20%; overflow:hidden;">
                <fieldset style="height:100%;">
                    <legend>程序清单</legend>
                    <div style="height:94%; overflow:hidden;">
                            <table data-toggle="tablefixed" data-width="100%" data-nowrap="true">
                                <thead>
                                <tr>
                                    <th width="20">No.</th>
                                    <th width="50" data-order-direction="" data-order-field="name">名称</th>
                                <#--<th width="100">是否发布</th>-->
                                    <th width="100">分组</th>
                                    <th width="100">业务类型</th>
                                    <th width="100">模板</th>
                                    <th width="100">危险提示</th>
                                </tr>
                                </thead>
                                <tbody>
                                <#list artifacts as row>
                                <tr data-id="${(row.id)!}">
                                    <td>${(row_index+1)!}</td>
                                    <td title="${(row.name)!}">${(row.name)!}</td>
                                    <input type="hidden" id="jobArtfactId" name="jobArtfactId" value="${(row.id)!}">
                                    <td>
                                        <select name="artifactGroupType" id="artifactGroupType" data-toggle="selectpicker" data-rule="required">
                                            <option value="">请选择</option>
                                            <#list groupTypes as groupType>
                                                <option value="${(groupType.groupType)!}" <#if groupType??&&groupType.groupType??&&job.groupType??&&groupType.groupType==job.groupType>selected</#if>>${(groupType.note)!}</option>
                                            </#list>
                                        </select>
                                    </td>
                                    <td>
                                        <select name="artfactBizType" id="artfactBizType" data-toggle="selectpicker" data-rule="required">
                                            <option value="">请选择</option>
                                            <#list bizTypes as bizType>
                                                <option value="${(bizType.typeName)!}" <#if bizType??&&bizType.typeName??&&job.bizType??&&bizType.typeName==job.bizType>selected</#if>>${(bizType.note)!}</option>
                                            </#list>
                                        </select>
                                    </td>

                                    <td>
                                        <input type="text" name="templateShellName" id="templateName_${(row.id)!}"  data-toggle="lookup" data-url="/admin/templateshell/lookup?paramId=${(row.id)!}"  data-width="1000" data-height="600" size="20" data-group="templateShell" readonly>
                                        <input type="hidden" name="templateShellId" id="templateId_${(row.id)!}">
                                    </td>
                                    <td <#if row.warnFlag>style="background-color:red"</#if>>
                                        <a href="/file/${(row.id)!}" target="_blank">预览文件</a>
                                    </td>
                                </tr>
                                </#list>
                                </tbody>
                            </table>
                    </div>
                </fieldset>
            </div>

        </div>
    </form>
</div>
<div class="bjui-pageFooter" >
    <ul>
        <li><button type="button" class="btn btn-close" data-icon="close">取消</button></li>
        <li><button type="submit" class="btn btn-success" data-icon="save">保存</button></li>
    </ul>
</div>
<script type="text/javascript">
    //选择事件
    function S_NodeCheck(e, treeId, treeNode) {
        var zTree = $.fn.zTree.getZTreeObj(treeId),
                nodes = zTree.getCheckedNodes(true)
        var ids = '', names = ''

        for (var i = 0; i < nodes.length; i++) {
            ids   += ','+ nodes[i].id
            names += ','+ nodes[i].name
        }
        if (ids.length > 0) {
            ids = ids.substr(1), names = names.substr(1)
        }

        var $from = $('#'+ treeId).data('fromObj')

        if ($from && $from.length) $from.val(names)
    }
    //单击事件
    function S_NodeClick(event, treeId, treeNode) {
        var zTree = $.fn.zTree.getZTreeObj(treeId)

        zTree.checkNode(treeNode, !treeNode.checked, true, true)

        event.preventDefault()
    }

    //时间控件初始化
    $('.secondDate').click(function() {
        $(this).datepicker({pattern:'yyyy-MM-dd HH:mm:00'});
    })
    //时间控件选择后，空值给予默认值
    $('.secondDate').on('afterchange.bjui.datepicker', function(e, data) {
        var mydate = data.value;
        $('.secondDate').each(function(){
            if($(this).val()=='')
            {
                $(this).val(mydate.formatDate('yyyy-MM-dd HH:mm:00'));
            }
        })
    })
    $('input[name="isTimer"]').on('ifChanged', function(e) {
        var val = $(this).val();
        if(val>0)
        {
            $('.secondDate').show();
        }
        else
        {
            $('.secondDate').hide();
        }

    })
</script>
